package com.example.im.controller;

import com.example.im.fegin.SearchApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IMController {
    @Autowired
    SearchApi searchApi;

    private String s;
    @GetMapping(value = "/index")
    public String index(){
               return "访问im成功"+ this.getPort();
    }

    @GetMapping(value = "/index1")
    public String index1(){
        return searchApi.search() + "im服务接口"+this.getPort();
    }

    private int getPort(){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return request.getLocalPort();
    }
    /** 第一次提交***/

    /** 第二次提交 **/
}
